def create_write_file():
    filename = input("请输入一个文件名：")
    text = input("请输入要写入的内容：")
    file = open(filename,"w")
    file.write(text)
    print(f"文件{filename}创建并写入成功！")

def read_file():
    filename = input("请输入要读取的文件名：")
    try:
        file = open(filename,"r")
        content = file.read()
        print("文件内容为：",content)
    except FileNotFoundError:
        print(f"{filename}文件读取异常")

def append_to_file():
    filename = input("请输入要追加的文件名：")
    text = input("请输入要追加的内容：")
    file = open(filename, "a")
    file.write(text)
    print(f"{text}已追加到文件{filename}中")

def myNotebook():
    while True:
        print("⭐️⭐️⭐️⭐️⭐️简单记事本程序/Bug⭐️⭐️⭐️⭐️")
        print("⭐️⭐️⭐️⭐️⭐️1.创建并写入文件⭐️⭐️⭐️⭐️⭐️")
        print("⭐️⭐️⭐️⭐️⭐2.读取文件⭐️⭐️⭐️⭐️⭐⭐⭐⭐")
        print("⭐️⭐️⭐️⭐️⭐3.追加文本到文件⭐️⭐️⭐️⭐️⭐")
        print("⭐️⭐️⭐️⭐️⭐4.退出!⭐️⭐️⭐️⭐️⭐⭐️⭐️⭐️⭐️")

        choice=input("请输入选项编号：")
        if choice == "1":
            create_write_file()#
        if choice == "2":
            read_file()
        if choice == "3":
            append_to_file()
        if choice == "4":
            break
if __name__ =="__main__":
    myNotebook()